
from lib.api import *
import re
from lib.urls import *

class API_1001:
    name = 'API_1001'       # 测试用例名字
    def teststeps(self):
        response = requests.post(url_Login+url_Login_API_Adress,  # 1
                                 json={"userAccount": "******************", "password": "******************"}
                                 )
        # auth_token = str(response.json()["data"]["token"])
        INFO('权限接口：用户，密码，token 测试   #1')
        INFO('前置条件：用户名 ****************** 正确，密码 ****************** 正确')
        expectedResult=json.dumps(json.loads(am.expectedResult()[0][3]),ensure_ascii=False,indent=4)
        outExpectedResult='预期结果:\n'+expectedResult
        INFO(outExpectedResult)
        am.printResponse(response)
        # print(auth_token)
        result = set(re.sub('\\s|{|}|\\[|]','',expectedResult).split(',')) ^ set(re.sub('\\s|{|}|\\[|]','',response.content.decode('utf8')).split(','))           #对比两个字符串中的不同并打印
        INFO('\n对比结果：\n'+str(result))
        CHECK_POINT('预期结果和输出结果是否保持一致',expectedResult==response.content.decode('utf8'))


class API_1002:
    name = 'API_1002'       # 测试用例名字
    def teststeps(self):
        response = requests.post(url_Login+url_Login_API_Adress,  # 1
                                 json={"userAccount": "******************", "password": "“'?cha查囓あØŌД₪∝⑧┿●﹌ㄝ   2333”"}
                                 )
        # auth_token = str(response.json()["data"]["token"])
        INFO('权限接口：用户，密码，token 测试   #1')
        INFO('前置条件：用户名 ****************** 正确，密码 “\'?cha查囓あØŌД₪∝⑧┿●﹌ㄝ   2333” 错误')
        expectedResult = json.dumps(json.loads(am.expectedResult()[1][3]), ensure_ascii=False, indent=4)
        outExpectedResult = '预期结果:\n' + expectedResult
        INFO(outExpectedResult)
        am.printResponse(response)
        # print(auth_token)
        result = set(re.sub('\\s|{|}|\\[|]','',expectedResult).split(',')) ^ set(re.sub('\\s|{|}|\\[|]','',response.content.decode('utf8')).split(','))           #对比两个字符串中的不同并打印
        INFO('\n对比结果：\n'+str(result))
        CHECK_POINT('预期结果和输出结果是否保持一致',expectedResult==response.content.decode('utf8'))


class API_1003:
    name = 'API_1003'       # 测试用例名字
    def teststeps(self):
        response = requests.post(url_Login+url_Login_API_Adress,  # 1
                                 json={"userAccount": "“'?cha查囓あØŌД₪∝⑧┿●﹌ㄝ   2333”", "password": "******************"}
                                 )
        # auth_token = str(response.json()["data"]["token"])
        INFO('权限接口：用户，密码，token 测试   #1')
        INFO('前置条件：用户名错误，密码正确')
        expectedResult = json.dumps(json.loads(am.expectedResult()[1][3]), ensure_ascii=False, indent=4)
        outExpectedResult = '预期结果:\n' + expectedResult
        INFO(outExpectedResult)
        am.printResponse(response)
        # print(auth_token)
        result = set(re.sub('\\s|{|}|\\[|]','',expectedResult).split(',')) ^ set(re.sub('\\s|{|}|\\[|]','',response.content.decode('utf8')).split(','))           #对比两个字符串中的不同并打印
        INFO('\n对比结果：\n'+str(result))
        CHECK_POINT('预期结果和输出结果是否保持一致',expectedResult==response.content.decode('utf8'))

class API_1004:
    name = 'API_1004'       # 测试用例名字
    def teststeps(self):
        response = requests.post(url_Login+url_Login_API_Adress,  # 1
                                 json={"userAccount": "******************", "password": "******************"}
                                 )
        # auth_token = str(response.json()["data"]["token"])
        INFO('权限接口：用户，密码，token 测试   #1')
        INFO('前置条件：用户名 ****************** 错误，密码 ****************** 错误')
        expectedResult = json.dumps(json.loads(am.expectedResult()[1][3]), ensure_ascii=False, indent=4)
        outExpectedResult = '预期结果:\n' + expectedResult
        INFO(outExpectedResult)
        am.printResponse(response)
        # print(auth_token)
        result = set(re.sub('\\s|{|}|\\[|]','',expectedResult).split(',')) ^ set(re.sub('\\s|{|}|\\[|]','',response.content.decode('utf8')).split(','))           #对比两个字符串中的不同并打印
        INFO('\n对比结果：\n'+str(result))
        CHECK_POINT('预期结果和输出结果是否保持一致',expectedResult==response.content.decode('utf8'))

class API_1005:
    name = 'API_1005'       # 测试用例名字
    def teststeps(self):
        response = requests.post(url_Login+url_Login_API_Adress,  # 1
                                 json={"userAccount": "******************", "password": ""}
                                 )
        # auth_token = str(response.json()["data"]["token"])
        INFO('权限接口：用户，密码，token 测试   #1')
        INFO('前置条件：只有用户名 ******************')
        expectedResult = json.dumps(json.loads(am.expectedResult()[1][3]), ensure_ascii=False, indent=4)
        outExpectedResult = '预期结果:\n' + expectedResult
        INFO(outExpectedResult)
        am.printResponse(response)
        # print(auth_token)
        result = set(re.sub('\\s|{|}|\\[|]','',expectedResult).split(',')) ^ set(re.sub('\\s|{|}|\\[|]','',response.content.decode('utf8')).split(','))           #对比两个字符串中的不同并打印
        INFO('\n对比结果：\n'+str(result))
        CHECK_POINT('预期结果和输出结果是否保持一致',expectedResult==response.content.decode('utf8'))


class API_1006:
    name = 'API_1006'       # 测试用例名字
    def teststeps(self):
        response = requests.post(url_Login+url_Login_API_Adress,  # 1
                                 json={"userAccount": "", "password": "******************"}
                                 )
        # auth_token = str(response.json()["data"]["token"])
        INFO('权限接口：用户，密码，token 测试   #1')
        INFO('前置条件：只有密码 ******************')
        expectedResult = json.dumps(json.loads(am.expectedResult()[1][3]), ensure_ascii=False, indent=4)
        outExpectedResult = '预期结果:\n' + expectedResult
        INFO(outExpectedResult)
        am.printResponse(response)
        # print(auth_token)
        result = set(re.sub('\\s|{|}|\\[|]','',expectedResult).split(',')) ^ set(re.sub('\\s|{|}|\\[|]','',response.content.decode('utf8')).split(','))           #对比两个字符串中的不同并打印
        INFO('\n对比结果：\n'+str(result))
        CHECK_POINT('预期结果和输出结果是否保持一致',expectedResult==response.content.decode('utf8'))


class API_1007:
    name = 'API_1007'       # 测试用例名字
    def teststeps(self):
        response = requests.post(url_Login+url_Login_API_Adress,  # 1
                                 json={"userAccount": "******************&******************", "password": ""}
                                 )
        # auth_token = str(response.json()["data"]["token"])
        INFO('权限接口：用户，密码，token 测试   #1')
        INFO('前置条件：只有用户名 ******************&****************** ')
        expectedResult = json.dumps(json.loads(am.expectedResult()[1][3]), ensure_ascii=False, indent=4)
        outExpectedResult = '预期结果:\n' + expectedResult
        INFO(outExpectedResult)
        am.printResponse(response)
        # print(auth_token)
        result = set(re.sub('\\s|{|}|\\[|]','',expectedResult).split(',')) ^ set(re.sub('\\s|{|}|\\[|]','',response.content.decode('utf8')).split(','))           #对比两个字符串中的不同并打印
        INFO('\n对比结果：\n'+str(result))
        CHECK_POINT('预期结果和输出结果是否保持一致',expectedResult==response.content.decode('utf8'))

class API_1008:
    name = 'API_1008'       # 测试用例名字
    def teststeps(self):
        response = requests.post(url_Login+url_Login_API_Adress,  # 1
                                 json={"userAccount": "", "password": "******************&******************"}
                                 )
        # auth_token = str(response.json()["data"]["token"])
        INFO('权限接口：用户，密码，token 测试   #1')
        INFO('前置条件：只有密码 ******************&******************')
        expectedResult = json.dumps(json.loads(am.expectedResult()[1][3]), ensure_ascii=False, indent=4)
        outExpectedResult = '预期结果:\n' + expectedResult
        INFO(outExpectedResult)
        am.printResponse(response)
        # print(auth_token)
        result = set(re.sub('\\s|{|}|\\[|]','',expectedResult).split(',')) ^ set(re.sub('\\s|{|}|\\[|]','',response.content.decode('utf8')).split(','))           #对比两个字符串中的不同并打印
        INFO('\n对比结果：\n'+str(result))
        CHECK_POINT('预期结果和输出结果是否保持一致',expectedResult==response.content.decode('utf8'))


class API_1009:
    name = 'API_1009'       # 测试用例名字
    def teststeps(self):
        response = requests.post(url_Login+url_Login_API_Adress,  # 1
                                 # json={"userAccount": "", "password": ""}
                                 )
        # auth_token = str(response.json()["data"]["token"])
        INFO('权限接口：用户，密码，token 测试   #1')
        INFO("'userAccount'为空, 'password'为空")
        expectedResult = json.dumps(json.loads(am.expectedResult()[1][3]), ensure_ascii=False, indent=4)
        outExpectedResult = '预期结果:\n' + expectedResult
        INFO(outExpectedResult)
        am.printResponse(response)
        # print(auth_token)
        result = set(re.sub('\\s|{|}|\\[|]','',expectedResult).split(',')) ^ set(re.sub('\\s|{|}|\\[|]','',response.content.decode('utf8')).split(','))           #对比两个字符串中的不同并打印
        INFO('\n对比结果：\n'+str(result))
        CHECK_POINT('预期结果和输出结果是否保持一致',expectedResult==response.content.decode('utf8'))



